/*

	Data Class to hold task information.


*/

#ifndef _DATA_h_
#define _DATA_h_

#include <iostream>
#include <map>
#include <cstring>
#include "date.h"
#ifndef Q_MOC_RUN
#include "boost\algorithm\string.hpp"
#endif

using namespace std;

enum TaskType {
	SCHEDULE, DEADLINE, FLOATING
};	

class Task
{
public:
	static int maxIndex;

private:
	bool valid;
	int id;
	string taskName;
	Date start; //Start date/time
	Date end; //End date/time or deadline.
	TaskType taskType;
	vector<string> categories;
	bool done;
	static bool containsSubsequence(string source, string target);

public:
	//Constructors
	Task(string st); // Construct from string
	Task();
	Task(bool valid);

	//@author A0105541U
	bool isValid();
	void setDone();
	void setUndone();
	bool fromString(string st);

	void setTaskName(string givenTaskName);
	void setStartEnd(Date givenStartTime, Date givenEndTime);
	void setDeadline(Date givenDeadline);
	void setFloating();
	//@author A0105541U
	void setCategories(vector<string> givenCategories);

	//@author A0105541U
	void addCategory(string category);

	//@author A0101728M
	bool isDone();
	bool isBefore(Date date);
	bool isAfter(Date date);
	bool isBetween(Date dateStart, Date dateEnd);
	bool isOver();
	bool isOverdue();
	bool isUpcoming();
	//@author A0105541U
	bool haveCategory(string category);
	bool nameContainsFuzzy(string target, int threshold); //threshold from 0-100
	bool nameContainsSubsequence(string subsq);
	bool categoriesContainSubsequence(string subsq);
	static bool categoryContainsSubsequence(string category, string subsq);
	
        // @author A0105541U
	string getTaskName();
	Date getStart();
	Date getEnd();
	int getId();
	TaskType getTaskType();
	vector<string> getCategories();

	// Inputing and outputing
	//@author A0105541U
	string toScreenString();
	string toFileString();
	string toTabledHTMLString();

	string toHTMLString();

};
#endif
